<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>活动列表 - 志愿服务管理系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/css/common.css}">
    <style>
        .activity-list-container {
            padding: var(--spacing-lg);
            max-width: 1200px;
            margin: 0 auto;
        }

        .activity-card {
            background: var(--background-white);
            border-radius: var(--border-radius-md);
            box-shadow: var(--shadow-sm);
            margin-bottom: var(--spacing-md);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            overflow: hidden;
        }

        .activity-card:hover {
            transform: translateY(-4px);
            box-shadow: var(--shadow-md);
        }

        .activity-header {
            background: linear-gradient(to right, var(--primary-color), var(--primary-dark));
            color: white;
            padding: var(--spacing-md) var(--spacing-lg);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .activity-header h3 {
            margin: 0;
            font-size: 1.2em;
        }

        .activity-content {
            padding: var(--spacing-lg);
        }

        .activity-info {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: var(--spacing-md);
            margin-bottom: var(--spacing-md);
        }

        .info-item {
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
            color: var(--text-secondary);
        }

        .info-item i {
            color: var(--primary-color);
            width: 20px;
        }

        .activity-description {
            color: var(--text-secondary);
            margin-bottom: var(--spacing-md);
            line-height: 1.6;
        }

        .activity-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--spacing-md) var(--spacing-lg);
            background-color: var(--background-light);
            border-top: 1px solid var(--border-color);
        }

        .activity-status {
            display: flex;
            align-items: center;
            gap: var(--spacing-sm);
        }

        .status-badge {
            padding: 4px 12px;
            border-radius: 12px;
            font-size: 0.9em;
            font-weight: 500;
        }

        .status-badge.active {
            background-color: #E8F5E9;
            color: var(--success-color);
        }

        .status-badge.ended {
            background-color: #FFEBEE;
            color: var(--danger-color);
        }

        .activity-actions {
            display: flex;
            gap: var(--spacing-sm);
        }

        .search-bar {
            margin-bottom: var(--spacing-lg);
            display: flex;
            gap: var(--spacing-md);
        }

        .search-input {
            flex: 1;
            position: relative;
        }

        .search-input i {
            position: absolute;
            left: var(--spacing-md);
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-secondary);
        }

        .search-input input {
            padding-left: calc(var(--spacing-md) * 2 + 16px);
            width: 100%;
        }

        .filters {
            display: flex;
            gap: var(--spacing-md);
            margin-bottom: var(--spacing-lg);
        }

        .filter-item {
            padding: var(--spacing-sm) var(--spacing-md);
            border-radius: var(--border-radius-sm);
            background-color: var(--background-white);
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .filter-item:hover,
        .filter-item.active {
            background-color: var(--primary-color);
            color: white;
        }

        .pagination {
            margin-top: var(--spacing-xl);
            justify-content: center;
        }

        @media (max-width: 768px) {
            .activity-info {
                grid-template-columns: 1fr;
            }

            .activity-footer {
                flex-direction: column;
                gap: var(--spacing-md);
                text-align: center;
            }

            .activity-actions {
                width: 100%;
                justify-content: center;
            }
        }
    </style>
</head>
<body>
    <div class="activity-list-container">


<!--        <div class="filters">-->
<!--            <div class="filter-item active">全部活动</div>-->
<!--            <div class="filter-item">进行中</div>-->
<!--            <div class="filter-item">已结束</div>-->
<!--            <div class="filter-item">即将开始</div>-->
<!--        </div>-->

        <div class="activity-list">
            <div class="activity-card" th:each="activity : ${activities}">
                <div class="activity-header">
                    <h3 th:text="${activity.activityName}">活动标题</h3>
                    <div class="status-badge" th:classappend="${activity.activityState == 0 ? 'badge-warning' : (activity.activityState == 1 ? 'active' : 'ended')}">
                        <span th:text="${activity.activityState == 0 ? '活动未开始' : (activity.activityState == 1 ? '活动进行中' : '活动已结束')}">活动状态</span>
                    </div>
                </div>
                <div class="activity-content">
                    <div class="activity-info">
                        <div class="info-item">
                            <i class="fas fa-calendar"></i>
                            <span th:text="${#dates.format(activity.startTime, 'yyyy-MM-dd HH:mm')}">开始时间</span>
                        </div>
                        <div class="info-item">
                            <i class="fas fa-map-marker-alt"></i>
                            <span th:text="${activity.activityAddress}">活动地点</span>
                        </div>
                        <div class="info-item">
                            <i class="fas fa-users"></i>
                            <span th:text="${activity.number}">总人数</span>
                        </div>
                        <div class="info-item">
                            <i class="fas fa-clock"></i>
                            <span th:text="${activity.sustain + '小时'}">活动时长</span>
                        </div>
                    </div>
                    <div class="activity-description" th:text="${activity.introduce}">
                        活动描述...
                    </div>
                </div>
                <div class="activity-footer">
                    <div class="activity-status">
                        <i class="fas fa-circle" th:classappend="${activity.enlistsState == 0 ? 'text-warning' : (activity.enlistsState == 1 ? 'text-success' : 'text-danger')}"></i>
                        <span th:text="${activity.enlistsState == 0 ? '报名未开始' : (activity.enlistsState == 1 ? '报名中' : '报名已结束')}">报名状态</span>
                    </div>
                    <div class="activity-actions">
                        <a th:href="@{'/toActivityDetail/'+${activity.id}}" class="btn btn-primary">
                            <i class="fas fa-info-circle me-2"></i>详情
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <!-- 分页导航 -->
        <nav aria-label="Page navigation" th:if="${totalPages > 1}" class="mt-4">
            <ul class="pagination justify-content-center">
                <!-- 首页 -->
                <li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
                    <!--跳转到第一页  如果当前页是第一页，则禁用该链接（添加 disabled 类）-->
                    <a class="page-link" th:href="@{/toActivityList(page=1)}" aria-label="First">
                        <span aria-hidden="true">&laquo;&laquo;</span>
                    </a>
                </li>
                
                <!-- 上一页 -->
                <li class="page-item" th:classappend="${currentPage == 1 ? 'disabled' : ''}">
                    <!--跳转到上一页  如果当前页是第一页，则禁用该链接（添加 disabled 类）-->
                    <a class="page-link" th:href="@{/toActivityList(page=${currentPage - 1})}" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
                
                <!-- 页码 -->
                <li class="page-item" th:each="pageNum : ${#numbers.sequence(0, totalPages - 1)}"
                    th:classappend="${pageNum + 1 == currentPage ? 'active' : ''}">
                    <a class="page-link" th:href="@{/toActivityList(page=${pageNum + 1})}" th:text="${pageNum + 1}"></a>
                </li>
                
                <!-- 下一页 -->
                <li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
                    <a class="page-link" th:href="@{/toActivityList(page=${currentPage + 1})}" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
                
                <!-- 末页 -->
                <li class="page-item" th:classappend="${currentPage == totalPages ? 'disabled' : ''}">
                    <a class="page-link" th:href="@{/toActivityList(page=${totalPages})}" aria-label="Last">
                        <span aria-hidden="true">&raquo;&raquo;</span>
                    </a>
                </li>
            </ul>
        </nav>

        <!-- 分页信息 -->
        <div class="pagination-info text-center mt-3" th:if="${totalItems > 0}">
            <div class="d-flex justify-content-center align-items-center">
                <span class="me-3">共 <span th:text="${totalItems}" class="fw-bold"></span> 条记录</span>
                <span class="mx-2">|</span>
                <span class="me-3">第 <span th:text="${currentPage}" class="fw-bold"></span> 页</span>
                <span class="mx-2">|</span>
                <span>共 <span th:text="${totalPages}" class="fw-bold"></span> 页</span>
            </div>
            <div class="mt-2">
                <small class="text-muted">每页显示 <span th:text="${pageSize}"></span> 条记录</small>
            </div>
        </div>

        <!-- 空状态提示 -->
        <div class="text-center py-5" th:if="${#lists.isEmpty(activities)}">
            <i class="fas fa-calendar-times fa-3x text-muted mb-3"></i>
            <h4 class="text-muted">暂无活动</h4>
            <p class="text-muted">当前没有可显示的活动信息</p>
        </div>
    </div>

    <script>
        // Filter functionality
        document.querySelectorAll('.filter-item').forEach(item => {
            item.addEventListener('click', function() {
                document.querySelectorAll('.filter-item').forEach(i => i.classList.remove('active'));
                this.classList.add('active');
                // Add filter logic here
            });
        });

        // Search functionality
        const searchInput = document.querySelector('.search-input input');
        searchInput.addEventListener('input', function() {
            // Add search logic here
            console.log('Searching for:', this.value);
        });

        // 添加页面加载动画
        $(document).ready(function() {
            $('.activity-card').each(function(index) {
                $(this).delay(index * 100).fadeIn(500);
            });
        });
    </script>
</body>
</html>